#pragma once

#include "imimedia_include.h"

typedef struct imimp4_ffmpeg_info_s *imimp4_ffmpeg_info_t;

void imimp4_init_ffmpeg();

int imimp4_create_file(const char* path,
	container_format_id container,
	video_codec_id video,
	audio_codec_id audio,
	unsigned int vfps,
	unsigned int vwidth,
	unsigned int vheight,
	unsigned int achannel,
	unsigned int asamplerate,
	/*out*/imimp4_ffmpeg_info_t* handle);

int imimp4_write_video_frame(imimp4_ffmpeg_info_t handle,
	unsigned char* data,
	unsigned int data_len,
	unsigned int vtimestamp,
	frame_type_id frametype);

int imimp4_write_audio_frame(imimp4_ffmpeg_info_t handle,
	unsigned char* data,
	unsigned int data_len,
	unsigned int atimestamp);

int imimp4_close_file_for_create(imimp4_ffmpeg_info_t handle);

int imimp4_open_file(const char* path,
	container_format_id* container,
	video_codec_id* video,
	audio_codec_id* audio,
	unsigned int* vfps,
	unsigned int* vwidth,
	unsigned int* vheight,
	unsigned int* achannel,
	unsigned int* asamplerate,
	unsigned int* abitrate,
	/*out*/imimp4_ffmpeg_info_t* handle);

int imimp4_get_frame(imimp4_ffmpeg_info_t handle,
	unsigned char* data,
	unsigned int* data_len,
	unsigned int* timestamp,
	frame_type_id* frametype);

int imimp4_seek_file(imimp4_ffmpeg_info_t handle,
	unsigned int timestamp);

int imimp4_close_file_for_open(imimp4_ffmpeg_info_t handle);